<?php
use common\utils\Com;
use yii\web\View;
$path = \yii\helpers\Url::to(['test/mobile']);
$path2 = yii\helpers\Url::to(['test/unique']);
$js = <<<Js
var ready = true;
$("#get").on("click",function(){
    if(ready){
        ready = false;
        $.post("{$path}",{url:$("#url").val()},function(json){
           if(json.code == 200){
               var t;
               $.each(json.data,function(i,n) {
                    t=100*i;
                    setTimeout(function() {
                      $.post("{$path}",{url:n},function(res) {
                          if(res.code == 200){
                            $("#txt").append('<p>'+res.data.telString+'|'+res.data.province+'|'+res.data.catName+'</p>')
                          }
                        },'json');
                    },t);
               });
               setTimeout(function() {
                 ready = true;
               },t);
           }else {
               ready = true;
           }
       },'json');
    }else{
        layer.msg("处理中...");
    }
    
});

var ready2 = true;
$("#get-2").on("click",function(){
    if(ready2){
        ready2 = false;
        $.post("{$path2}",{url:$("#url-2").val()},function(json){
            ready2 = true;
           if(json.code == 200){
               $("#txt-2").html("");
               $.each(json.data,function(i,n) {
                    $("#txt-2").append('<p>'+n+'</p>')
               });
               if((json.data).length == 0){
                    alert("本次的所有号码都已经重复了。");
               }else{
                    alert("本次共有不重复号码"+(json.data).length+"条，已显示在下方，请复制后处理。");
               }
               
           }
       },'json');
    }else{
        layer.msg("处理中...");
    }
    
});
Js;
$this->registerJsFile("/js/layer/layer.js?t=".Com::v(),[
    'position'=>\yii\web\View::POS_END
]);
$this->registerJs($js,\yii\web\View::POS_END);

?>
<textarea type="text" id="url-2" style="width: 100%;height: 100px;" placeholder="(示例：换行区分不同手机号)
12345769522
12345769522
12345769522"></textarea>
<button id="get-2">手机号码去重</button>
<div id="txt-2" style="width: 100%;min-height: 100px;" contenteditable="true">

</div>
<br />
<br />
<br />
<br />
<textarea type="text" id="url" style="width: 100%;height: 100px;" placeholder="(示例：换行区分不同手机号)
12345769522
12345769522
12345769522"></textarea>
<button id="get">分析手机运营商</button>
<a href="<?=\yii\helpers\Url::to(['test/mobile-out'])?>">前往导出数据</a>
<div id="txt" style="width: 100%;min-height: 100px;" contenteditable="true">

</div>


